<?
	/*
	 * @since 2012.03.27
	 * @author Charles Koh
	 * @returns {Register page 1}
	 */
	$sponsor_id = $_POST['sponsor_id'];
	
?>
<html>
<head>
	<link rel="stylesheet" href="../../css/common.css"/>
	<script type="text/javascript" src="../../js/common.js"></script>
	<script>
	function check_email()
	{
		ajax.request({
			url:"check_email.php",
			type:"GET",
			data:"email=" + document.step_2_sponsor.email_id.value + "@" + document.step_2_sponsor.email_host.value,
			dataType:"json",
			successCB: function (json) {
				alert(json.message);
				email_check = (json.data && json.data[0]) || 0;
				email_input_disable(true);
			}
		});
	}
	function email_input_disable(flag) {
		document.step_2_sponsor.email_id.disabled = flag;
		document.step_2_sponsor.email_host.disabled = flag;
	}
	function region_change()
	{
		document.getElementById('selected_region').innerHTML = document.step_2_sponsor.country.value;
	}
	
	function check_input_submit()
	{
		document.step_2_sponsor.sponsor_id.value = "<?echo "$sponsor_id";?>";
		
		if (!document.step_2_sponsor.full_name.value)
		{
			alert("No input Name");    
			document.register_form.full_name.focus();
			return;
		}

		if (!document.step_2_sponsor.email_id.value)
		{
			alert("No input email");    
			document.step_2_sponsor.email_id.focus();
			return;
		}

		if (!document.step_2_sponsor.email_id.disabled)
		{
			alert("Not check for your e-mail");    
			return;
		}
		
		if (!document.step_2_sponsor.email_host.value)
		{
			alert("Not selected email host");    
			document.step_2_sponsor.email_host.focus();
			return;
		}
		
		if (!document.step_2_sponsor.phone_reg.value)
		{
			alert("Not selected region");    
			document.step_2_sponsor.phone_reg.focus();
			return;
		}
		
		if (!document.step_2_sponsor.phone_num.value)
		{
			alert("No input phone number");    
			document.step_2_sponsor.phone_num.focus();
			return;
		}
		
		if (!document.step_2_sponsor.country.value)
		{
			alert("Not selected country");    
			document.step_2_sponsor.country.focus();
			return;
		}
		
		email_input_disable(false);
		document.step_2_sponsor.submit();
	}

	function reset_form()
	{
		document.step_2_sponsor.full_name.value = "";
		document.step_2_sponsor.email_id.value = "";
		document.step_2_sponsor.email_host.value = "";
		document.step_2_sponsor.phone_reg.value = "";
		document.step_2_sponsor.phone_num.value = "";
		document.step_2_sponsor.country.value = "";
		      
		document.step_2_sponsor.id.focus();

		return;
	}
	

	</script>
</head>

<body>

	<!--Step 2-->
	<div id="reg_step_2">
		<b>Register</b><br/><br/>
		<span>2 Step: private info</span><br/><br/>
		<form name="step_2_sponsor" action="register.php" method="POST">
		<table border=0 cellspacing=0 cellpadding=0 align=center width="682" >
			<tr>
				<td>Full Name</td>
				<td colspan="2">
					<input type="text" name="full_name" max="20" maxlength="20">
					<input type="text" name="sponsor_id" max="10" maxlength="10" style="display:none;">
				</td>
			</tr>
			<tr>
				<td>E-mail</td>
				<td><input type="text" name="email_id" max="20" maxlength="20"> @ <input type="text" name="email_host" max="20" maxlength="20"></td>
				<td><input type="button" value="Check" onclick="check_email()"/></td>
			</tr>
			<tr>
				<td>Phone Number</td>
				<td colspan="2">
					<select name="phone_reg">
						<option value='000'>select</option>
						<option value='001'>US</option>
						<option value='082'>Korea</option>
					</select>
					<input type="text" name="phone_num" max="13" maxlength="13">
				</td>
			</tr>
			<tr>
				<td>Country</td>
				<td colspan="2">
					<select name="country" onchange="region_change()">
						<option value=''>select</option>
						<option value='US'>US</option>
						<option value='Korea'>Korea</option>
					</select>
					<span id="selected_region"></span>
				</td>
			</tr>
			<tr>
				<td></td>
				<td colspan="2">
					<input type="button" value="next" onclick="check_input_submit()"/>
					<input type="button" value="modify" onclick="javascript:email_input_disable(false);"/>
				</td>
			</tr>	
		</table>
		</form>
	</div><!--Step 2-->
  </body>
</html>